#ifndef CSmath_H
#define CSmath_H

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
class CSmath
{
public:
	enum {
		SampleAlg = 250,
		Gain = 3,
		TmpRateMv1 = (17 * Gain),
		MV1 = (20971 / TmpRateMv1)//270ul
	};
	CSmath();
	~CSmath();
	int Min_Alg(int a, int b);
	int Max_Alg(int a, int b);
	int Mean_Alg(int* member, int qidian, int weidian);
	int Mean_abs_Alg(int* member, int qidian, int weidian);
	int GetIndexMin_Alg(int* ppData_x, int index_start, int index_end);
	int GetIndexMax_Alg(int* ppData_x, int index_start, int index_end);
	int Abs_Alg(int a);
	float SmoothAverage_Alg(float last,float now);
	
	void Sort_int(int *p_su, int numSort);
	int abs_max(int *p, int left, int right);
	int chafen_2rd_Q(int *p_Data_x, int data_begin, int *p_2rd, int * p_1st, int R_point, int thr_Q, int Y1_B, int TimeareaQR);
	int chafen_2rd_S(int *p_Data_x, int data_begin, int *p_2rd, int * p_1st, int R_point, int thr_S, int TimeareaRS);
	int Calculate_exact_S(int *p_ptr, int temp_S1, int time_S);
	int calculate_chafen_banjing_for_Q(int * p_ptr, int left, int weizhi_R);
	int calculate_chafen_banjing_for_S(int * p_ptr, int weizhi_R, int right);
};

#endif
